<template>
  <el-container style="height: 100%">
    <el-aside width="200px" v-if="$route.path !== '/login'" style="background-color: #545c64">
      <el-menu
        background-color="#545c64"
        text-color="#fff"
        :router="true"
        active-text-color="#ffd04b"
        style="border: none;"
        default-active="/">
        <el-menu-item index="/">盆栽管理</el-menu-item>
        <el-menu-item index="/duorou">多肉管理</el-menu-item>
      </el-menu>
    </el-aside>
    <el-container>
      <el-header style="background-color: #409EFF;" v-if="$route.path !== '/login'">
        <el-row>
          <el-col :span="24">
            <div class="user-name">{{userName}}</div>
          </el-col>
        </el-row>
      </el-header>
      <el-main :style="{ padding: $route.path === '/login' ? '0' : '20px' }">
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
export default {
  computed: {
    userName () {
      const user = JSON.parse(localStorage.getItem('user'))
      return user && user.name
    }
  }
}
</script>

<style>
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

.user-name {
  text-align: right;
  line-height: 60px;
  color: #fff;
}
</style>
